home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c,comp.std.c,finet.atk.kielet.c
- Subject: Re: TYPEDEF and Watcom C++ 10.5
- Date: Wed, 03 Apr 96 16:49:42 GMT
- Organization: none
- Distribution: world
- Message-ID: <828550182snz@genesis.demon.co.uk>
- References: <4jlu1r$cs7@nic.dataphone.se>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4jlu1r$cs7@nic.dataphone.se>
- skorpio@dataphone.se "Jarmo Paavilainen" writes:
-
- >
- >typedef struct
- >{
- >WORD CheckSum;
- >WORD Version;
- >BYTE PatchLevel;
- >BYTE Name[21];
- >WORD MarkerVersion;
- >}VERSION_TAG_STRUCT;
- >
- >Shouldn't sizeof(VERSION_TAG_STRUCT) always result in 28. By other words
- >shouldn't WORD always be 16 bits and BYTE 8 bits.
-
- BYTE and WORD aren't defined by the C language so it is up to your
- implementation or whatever code defined them to select a suitable C type
- for them.
-
- Also be aware that compilers can add padding anywhere in a structure (except
- before the first member), usually to ensure that the members are aligned
- appropriately.
-
- >If so why does my compiler claim that sizeof(VERSION_TAG_STRUCT) == 34.
- >All this in 32 bit OS/2 PM and Watcom C++ 10.5
-
- Why don't you check what sizeof(WORD) is on your system by writing a program
- to print it out (sizeof(BYTE) can't be more than 1 with the size of the
- whole structure being 34).
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-